package com.ruitu.health_2.ui.common;

import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ruitu.arad.base.BaseActivity;
import com.ruitu.arad.base.BaseModel;
import com.ruitu.arad.base.BasePresenter;
import com.ruitu.health_2.R;
import com.ruitu.health_2.ui.adapter.CommonProListAdapter;
import com.ruitu.health_2.ui.adapter.ModelArtManListAdapter;
import com.ruitu.health_2.ui.adapter.ModelArticleListAdapter;
import com.ruitu.health_2.ui.adapter.ModelVideoListAdapter;
import com.ruitu.router_module.bean.article.Article;
import com.ruitu.router_module.bean.home.AdvertContent;
import com.ruitu.router_module.bean.home.ModelData;
import com.ruitu.router_module.bean.product.ArtMan;
import com.ruitu.router_module.bean.product.ProHome;
import com.ruitu.router_module.bean.product.Video;
import com.youth.banner.Banner;

import java.util.ArrayList;
import java.util.List;

import androidx.recyclerview.widget.RecyclerView;

// 八个模块的基类
public abstract class BaseModelActivity<P extends BasePresenter, M extends BaseModel> extends BaseActivity<P, M> {
    protected Banner banner;// banner
    protected ImageView iv_1, iv_2;
    // 艺人 视频 文章 商品 (四个列表,实际每个模块的排列顺序可能不同)
    protected RecyclerView rcv_list, rcv_list_2, rcv_list_3, rcv_list_4;
    protected TextView tv_empty_1, tv_empty_2, tv_empty_3, tv_empty_4;// 四个空白view

    // banner数据
    protected List<AdvertContent> bannerList = new ArrayList<>();
    // 艺人
    protected List<ArtMan> artManList = new ArrayList<>();
    protected ModelArtManListAdapter artManAdapter;
    // 视频
    protected List<Video> videoList = new ArrayList<>();
    protected ModelVideoListAdapter videoAdapter;
    // 文章
    protected List<Article> articleList;
    protected ModelArticleListAdapter articleAdapter;
    // 商品
    protected List<ProHome> proList = new ArrayList<>();
    protected CommonProListAdapter proAdapter;//

    protected ModelData modelData;// 请求得到的模块数据

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        banner = findViewById(R.id.banner);
        iv_1 = findViewById(R.id.iv_1);
        iv_2 = findViewById(R.id.iv_2);
        rcv_list = findViewById(R.id.rcv_list);
        rcv_list_2 = findViewById(R.id.rcv_list_2);
        rcv_list_3 = findViewById(R.id.rcv_list_3);
        rcv_list_4 = findViewById(R.id.rcv_list_4);
        tv_empty_1 = findViewById(R.id.tv_empty_1);
        tv_empty_2 = findViewById(R.id.tv_empty_2);
        tv_empty_3 = findViewById(R.id.tv_empty_3);
        tv_empty_4 = findViewById(R.id.tv_empty_4);
    }

    @Override
    public void onReqComplete(int code, boolean isOk, Object data) {
        if (!isDataEmpty(artManList)) {
            tv_empty_1.setVisibility(View.GONE);
        }
        if (!isDataEmpty(videoList)) {
            tv_empty_2.setVisibility(View.GONE);
        }
        if (!isDataEmpty(articleList)) {
            tv_empty_3.setVisibility(View.GONE);
        }
        if (!isDataEmpty(proList)) {
            tv_empty_4.setVisibility(View.GONE);
        }
    }
}
